<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>数据上报</title>

    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="font-awesome/css/font-awesome.css" rel="stylesheet">
    <link href="css/plugins/dataTables/datatables.min.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

</head>

<body>

<div id="wrapper">

    <!--引入公共页面-->
    <div th:replace="common/sidebar::sidebar(activeUri='examee-uploadData')"></div>
    <!--当前用户的账户信息-->
    <input type="hidden" id="current_user" th:value="${session.userAccount}">

    <div id="page-wrapper" class="gray-bg">
        <div class="row border-bottom">
            <nav class="navbar navbar-static-top white-bg" role="navigation" style="margin-bottom: 0">
                <div class="navbar-header">
                    <a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="#"><i class="fa fa-bars"></i> </a>
                    <form role="search" class="navbar-form-custom" method="post" action="#">
                        <div class="form-group">
                            <input type="text" placeholder="Search for something..." class="form-control" name="top-search" id="top-search">
                        </div>
                    </form>
                </div>
                <ul class="nav navbar-top-links navbar-right">
                    <li>
                        <a href="#">
                            <i class="fa fa-sign-out"></i> Log out
                        </a>
                    </li>
                </ul>

            </nav>
        </div>
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox ">
                        <div class="ibox-title">
                            <h5>当前候考室剩余签号</h5>
                            <div class="ibox-tools">
                                <a class="collapse-link">
                                    <i class="fa fa-chevron-up"></i>
                                </a>
                                <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                                    <i class="fa fa-wrench"></i>
                                </a>

                            </div>
                        </div>
                        <div class="ibox-content">
                            <div class="alert alert-warning">
                                当前候考室缺考信息： <a class="alert-link" href="#" id="waitingRoom_absent"></a>.
                            </div>

                        </div>
                    </div>
                </div>
                <div class="col-lg-12">
                    <div class="ibox ">
                        <div class="ibox-title">
                            <h5>抽签结果</h5>
                            <button class="btn btn-success btn-xs" type="button"  onclick="upLoadDrawLotsAndAbsent()"><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">上报抽签及缺考信息</span></button>
                            <div class="ibox-tools">
                                <a class="collapse-link">
                                    <i class="fa fa-chevron-up"></i>
                                </a>
                                <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                                    <i class="fa fa-wrench"></i>
                                </a>
                                <ul class="dropdown-menu dropdown-user">
                                    <li><a href="#" class="dropdown-item">Config option 1</a>
                                    </li>
                                    <li><a href="#" class="dropdown-item">Config option 2</a>
                                    </li>
                                </ul>
                                <a class="close-link">
                                    <i class="fa fa-times"></i>
                                </a>
                            </div>
                        </div>
                        <div class="ibox-content">

                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover dataTables-example" id="table_examee">
                                    <thead>
                                    <tr>
                                        <th>身份证号</th>
                                        <th>抽签号</th>
                                        <th>所属组</th>
                                    </tr>
                                    </thead>
                                    <tbody>

                                    </tbody>
                                    <tfoot>
                                    </tfoot>
                                </table>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="footer">
            <div class="pull-right">
                10GB of <strong>250GB</strong> Free.
            </div>
            <div>
                <strong>Copyright</strong> Example Company &copy; 2014-2018
            </div>
        </div>

    </div>
</div>

<!--Mainly scripts-->
<script type="text/javascript" th:src="@{js/jquery-3.1.1.min.js}"></script>
<script type="text/javascript" th:src="@{js/popper.min.js}"></script>
<script type="text/javascript" th:src="@{js/bootstrap.min.js}"></script>
<script type="text/javascript" th:src="@{js/plugins/metisMenu/jquery.metisMenu.js}"></script>
<script type="text/javascript" th:src="@{js/plugins/slimscroll/jquery.slimscroll.min.js}"></script>

<script type="text/javascript" th:src="@{js/plugins/dataTables/datatables.min.js}"></script>
<script type="text/javascript" th:src="@{js/plugins/dataTables/dataTables.bootstrap4.min.js}"></script>

<!-- Custom and plugin javascript -->
<script type="text/javascript" th:src="@{js/inspinia.js}"></script>
<script type="text/javascript" th:src="@{js/plugins/pace/pace.min.js}"></script>

<!-- Page-Level Scripts -->
<script>
    $(document).ready(function() {
        init();
        getAbsent();
    });
    function init() {
        $.ajax({
            url:"/drawLots/getDrawLotsList",
            type:"POST",
            success:function (result) {
                var drawLots=result.data;
                <!--构建表格-->
                $("#table_examee").DataTable({
                    data:drawLots,
                    paging: false,
                    responsive: true,
                    processing: true,
                    dataType : 'json',
                    dom: '<"html5buttons"B>lTfgitp',
                    buttons: [
                        {
                            extend: 'excel',
                            title: 'ExampleFile'
                        },
                        {
                            extend: 'pdf',
                            title: 'ExampleFile'
                        },

                        {
                            extend: 'print',
                            customize: function(win) {
                                $(win.document.body).addClass('white-bg');
                                $(win.document.body).css('font-size', '10px');

                                $(win.document.body).find('table')
                                    .addClass('compact')
                                    .css('font-size', 'inherit');
                            }
                        }
                    ],
                    columns:[
                        {"data":"idNumber"},
                        {"data":"drawLotsNumber"},
                        {"data":"groupId"}
                    ]
                });
            }
        });
    }

    function getAbsent() {
        $.ajax({
            url:"/schedule/getRemainingDrawLots",
            type: "POST",
            success:function (result) {
                var tag=result.flag;
                if (tag==false){
                    alert("当前考场没有缺考信息");
                    $("#waitingRoom_absent").text("无缺考")
                }else {
                    var data=result.data;
                    var resultArray = data.map(function(item) {
                        return "【"+item.groupId + "组缺考考生编号： " + item.absent+"】";
                    });
                    // 使用 join 方法将数组中的字符串拼接成一个单一的字符串
                    var resultString = resultArray.join(", ");
                    $("#waitingRoom_absent").text(resultString)
                    initTable();
                }
            }
        })
    }

    //上报抽签及缺考结果
    function upLoadDrawLotsAndAbsent() {
        $.ajax({
            url:"/drawLots/upLoadDrawLotsAndAbsentInfo",
            type: "POST",
            success:function (result) {
                alert(result.message);

            }
        })
    }
</script>
</body>

</html>
